import requests
from bs4 import BeautifulSoup

url = 'http://www.baidu.com'
r = requests.get(url)
r.encoding = 'utf-8'
html = r.text
soup = BeautifulSoup(html, 'lxml')
print(soup.prettify())    # 格式化
print(soup.title)         # <title>???</title>  -----> 获取整个
print(soup.title.string)  # <title>???</title>  -----> 获取???
print(soup.html.name)     # <html>???</html> ----->  获取标签名字即 html
print(soup.link['href'])  # <link href=???> ----->  获取???
